﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BoolanSlide.UI;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;

namespace BoolanElement.UI.TextBox
{
    class ShapeFontSettingHelper
    {
        #region 初始化字体样式按钮
        Windows.UI.Xaml.Media.Imaging.BitmapImage BoldImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage BoldImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage BoldImageDisable;
        Windows.UI.Xaml.Media.Imaging.BitmapImage BoldSelectedImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage BoldSelectedImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage BoldSelectedImageDisable;
        public ImageButton BoldButton;
        public void InitBoldButton(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            List<BitmapImage> ImageNormal = new List<BitmapImage>();
            ImageNormal.Add(BoldImageNormal);
            ImageNormal.Add(BoldSelectedImageNormal);
            List<BitmapImage> ImageDown = new List<BitmapImage>();
            ImageDown.Add(BoldImageDown);
            ImageDown.Add(BoldSelectedImageDown);
            List<BitmapImage> ImageDisable = new List<BitmapImage>();
            ImageDisable.Add(BoldImageDisable);
            ImageDisable.Add(BoldSelectedImageDisable);

            BoldButton = new ImageButton(container, 2, ImageNormal, ImageDown, ImageDisable);
            BoldButton.Click += btnClickHandler;
        }


        Windows.UI.Xaml.Media.Imaging.BitmapImage ItalicImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage ItalicImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage ItalicImageDisable;
        Windows.UI.Xaml.Media.Imaging.BitmapImage ItalicSelectedImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage ItalicSelectedImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage ItalicSelectedImageDisable;
        public ImageButton ItalicButton;
        public void InitItalicButton(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            List<BitmapImage> ImageNormal = new List<BitmapImage>();
            ImageNormal.Add(ItalicImageNormal);
            ImageNormal.Add(ItalicSelectedImageNormal);
            List<BitmapImage> ImageDown = new List<BitmapImage>();
            ImageDown.Add(ItalicImageDown);
            ImageDown.Add(ItalicSelectedImageDown);
            List<BitmapImage> ImageDisable = new List<BitmapImage>();
            ImageDisable.Add(ItalicImageDisable);
            ImageDisable.Add(ItalicSelectedImageDisable);

            ItalicButton = new ImageButton(container, 2, ImageNormal, ImageDown, ImageDisable);
            ItalicButton.Click += btnClickHandler;
        }


        Windows.UI.Xaml.Media.Imaging.BitmapImage UnderLineImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage UnderLineImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage UnderLineImageDisable;
        Windows.UI.Xaml.Media.Imaging.BitmapImage UnderLineSelectedImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage UnderLineSelectedImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage UnderLineSelectedImageDisable;
        public ImageButton UnderLineButton;
        public void InitUnderLineButton(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            List<BitmapImage> ImageNormal = new List<BitmapImage>();
            ImageNormal.Add(UnderLineImageNormal);
            ImageNormal.Add(UnderLineSelectedImageNormal);
            List<BitmapImage> ImageDown = new List<BitmapImage>();
            ImageDown.Add(UnderLineImageDown);
            ImageDown.Add(UnderLineSelectedImageDown);
            List<BitmapImage> ImageDisable = new List<BitmapImage>();
            ImageDisable.Add(UnderLineImageDisable);
            ImageDisable.Add(UnderLineSelectedImageDisable);

            UnderLineButton = new ImageButton(container, 2, ImageNormal, ImageDown, ImageDisable);
            UnderLineButton.Click += btnClickHandler;
        }

        Windows.UI.Xaml.Media.Imaging.BitmapImage StrikeoutImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage StrikeoutImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage StrikeoutImageDisable;
        Windows.UI.Xaml.Media.Imaging.BitmapImage StrikeoutSelectedImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage StrikeoutSelectedImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage StrikeoutSelectedImageDisable;
        public ImageButton StrikethroughButton;
        public void InitStrikeoutButton(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            List<BitmapImage> ImageNormal = new List<BitmapImage>();
            ImageNormal.Add(StrikeoutImageNormal);
            ImageNormal.Add(StrikeoutSelectedImageNormal);
            List<BitmapImage> ImageDown = new List<BitmapImage>();
            ImageDown.Add(StrikeoutImageDown);
            ImageDown.Add(StrikeoutSelectedImageDown);
            List<BitmapImage> ImageDisable = new List<BitmapImage>();
            ImageDisable.Add(StrikeoutImageDisable);
            ImageDisable.Add(StrikeoutSelectedImageDisable);

            StrikethroughButton = new ImageButton(container, 2, ImageNormal, ImageDown, ImageDisable);
            StrikethroughButton.Click += btnClickHandler;
        }
        #endregion 初始化字体样式按钮

        #region 初始化字体对齐方式
        BitmapImage LeftTopImageNormal;
        BitmapImage LeftTopImageDown;
        BitmapImage LeftTopImageDisable;
        private ImageButton LeftTopButton;
        public void InitLeftTop(Image container, ButtonClickHandler btnClickHandler)
        {
            LeftTopButton = new ImageButton(container, LeftTopImageNormal, LeftTopImageDown, LeftTopImageDisable);
            LeftTopButton.Click += btnClickHandler;
        }

        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterTopImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterTopImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterTopImageDisable;
        private ImageButton CenterTopButton;
        public void InitCenterTop(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            CenterTopButton = new ImageButton(container, CenterTopImageNormal, CenterTopImageDown, CenterTopImageDisable);
            CenterTopButton.Click += btnClickHandler;
        }

        Windows.UI.Xaml.Media.Imaging.BitmapImage RightTopImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightTopImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightTopImageDisable;
        private ImageButton RightTopButton;
        public void InitRightTop(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            RightTopButton = new ImageButton(container, RightTopImageNormal, RightTopImageDown, RightTopImageDisable);
            RightTopButton.Click += btnClickHandler;
        }

        Windows.UI.Xaml.Media.Imaging.BitmapImage LeftCenterImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage LeftCenterImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage LeftCenterImageDisable;
        private ImageButton LeftCenterButton;
        public void InitLeftCenter(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            LeftCenterButton = new ImageButton(container, LeftCenterImageNormal, LeftCenterImageDown, LeftCenterImageDisable);
            LeftCenterButton.Click += btnClickHandler;
        }

        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterCenterImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterCenterImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterCenterImageDisable;
        private ImageButton CenterCenterButton;
        public void InitCenterCenter(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            CenterCenterButton = new ImageButton(container, CenterCenterImageNormal, CenterCenterImageDown, CenterCenterImageDisable);
            CenterCenterButton.Click += btnClickHandler;
        }

        Windows.UI.Xaml.Media.Imaging.BitmapImage RightCenterImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightCenterImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightCenterImageDisable;
        private ImageButton RightCenterButton;
        public void InitRightCenter(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            RightCenterButton = new ImageButton(container, RightCenterImageNormal, RightCenterImageDown, RightCenterImageDisable);
            RightCenterButton.Click += btnClickHandler;
        }
            
        Windows.UI.Xaml.Media.Imaging.BitmapImage LeftBottomImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage LeftBottomImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage LeftBottomImageDisable;
        private ImageButton LeftBottomButton;
        public void InitLeftBottom(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            LeftBottomButton = new ImageButton(container, LeftBottomImageNormal, LeftBottomImageDown, LeftBottomImageDisable);
            LeftBottomButton.Click += btnClickHandler;
        }
            
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterBottomImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterBottomImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage CenterBottomImageDisable;
        private ImageButton CenterBottomButton;
        public void InitCenterBottom(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            CenterBottomButton = new ImageButton(container, CenterBottomImageNormal, CenterBottomImageDown, CenterBottomImageDisable);
            CenterBottomButton.Click += btnClickHandler;
        }
            
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightBottomImageNormal;
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightBottomImageDown;
        Windows.UI.Xaml.Media.Imaging.BitmapImage RightBottomImageDisable;
        private ImageButton RightBottomButton;
        public void InitRightBottom(Windows.UI.Xaml.Controls.Image container, ButtonClickHandler btnClickHandler)
        {
            RightBottomButton = new ImageButton(container, RightBottomImageNormal, RightBottomImageDown, RightBottomImageDisable);
            RightBottomButton.Click += btnClickHandler;
        }
        #endregion 初始化字体对齐方式

        public ShapeFontSettingHelper()
        {
            LoadImageSource();
        }

        private void LoadImageSource()
        {
            string prefix = "ms-appx:/";
            BoldImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix +"images/Bold.png"));
            BoldImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Bold.png"));
            BoldImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Bold.png"));
            BoldSelectedImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/BoldSelected.png"));
            BoldSelectedImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/BoldSelected.png"));
            BoldSelectedImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/BoldSelected.png"));

            ItalicImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Italic.png"));
            ItalicImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Italic.png"));
            ItalicImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Italic.png"));
            ItalicSelectedImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/ItalicSelected.png"));
            ItalicSelectedImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/ItalicSelected.png"));
            ItalicSelectedImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/ItalicSelected.png"));

            UnderLineImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/UnderLine.png"));
            UnderLineImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/UnderLine.png"));
            UnderLineImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/UnderLine.png"));
            UnderLineSelectedImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/UnderLineSelected.png"));
            UnderLineSelectedImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/UnderLineSelected.png"));
            UnderLineSelectedImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/UnderLineSelected.png"));

            StrikeoutImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Strikeout.png"));
            StrikeoutImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Strikeout.png"));
            StrikeoutImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/Strikeout.png"));
            StrikeoutSelectedImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/StrikeoutSelected.png"));
            StrikeoutSelectedImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/StrikeoutSelected.png"));
            StrikeoutSelectedImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/StrikeoutSelected.png"));

            LeftTopImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftTop.png"));
            LeftTopImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftTop.png"));
            LeftTopImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftTopDisable.png"));

            CenterTopImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterTop.png"));
            CenterTopImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterTop.png"));
            CenterTopImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterTopDisable.png"));

            RightTopImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightTop.png"));
            RightTopImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightTop.png"));
            RightTopImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightTopDisable.png"));

            LeftCenterImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftCenter.png"));
            LeftCenterImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftCenter.png"));
            LeftCenterImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftCenterDisable.png"));

            CenterCenterImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterCenter.png"));
            CenterCenterImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterCenter.png"));
            CenterCenterImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterCenterDisable.png"));

            RightCenterImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightCenter.png"));
            RightCenterImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightCenter.png"));
            RightCenterImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightCenterDisable.png"));

            LeftBottomImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftBottom.png"));
            LeftBottomImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftBottom.png"));
            LeftBottomImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/LeftBottomDisable.png"));

            CenterBottomImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterBottom.png"));
            CenterBottomImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterBottom.png"));
            CenterBottomImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/CenterBottomDisable.png"));

            RightBottomImageNormal = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightBottom.png"));
            RightBottomImageDown = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightBottom.png"));
            RightBottomImageDisable = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(prefix + "images/RightBottomDisable.png"));
        }

        public void UpdateTextAlignment(Configuration.TextAlignment textAlignment)
        {
            if (LeftTopButton == null)
                return;

            LeftTopButton.IsEnabled = true;
            CenterTopButton.IsEnabled = true;
            RightTopButton.IsEnabled = true;
            LeftCenterButton.IsEnabled = true;
            CenterCenterButton.IsEnabled = true;
            RightCenterButton.IsEnabled = true;
            LeftBottomButton.IsEnabled = true;
            CenterBottomButton.IsEnabled = true;
            RightBottomButton.IsEnabled = true;

            switch (textAlignment)
            {
                case Configuration.TextAlignment.LeftTop:
                    LeftTopButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.CenterTop:
                    CenterTopButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.RightTop:
                    RightTopButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.LeftCenter:
                    LeftCenterButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.CenterCenter:
                    CenterCenterButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.RightCenter:
                    RightCenterButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.LeftBottom:
                    LeftBottomButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.CenterBottom:
                    CenterBottomButton.IsEnabled = false;
                    break;
                case Configuration.TextAlignment.RightBottom:
                    RightBottomButton.IsEnabled = false;
                    break;
                default:
                    break;

            }
        }
    }
}
